/**
 * Created by moonlight on 2015/6/12.
 */
$(document).ready(function(){
    var username =  $('#username').text();
   // console.log(username);
    //编辑个人信息
        $('#btn-userInfo').click(function(){
           var form ='';
            form = "<form class='userInfoEditForm'>" + "用户名：<input type='text' class='form-control' readonly='true' name='user_name' value='" + username + "'><br />" + "昵称：<input type='text' class='form-control' name='nickname'><br />" + "性别：<input type='radio' class='radio-inline' name='sex' value='m' checked>男 <input type='radio' class='radio-inline' name='sex' value='f' >女<br />" + "出生日期：" +
            "<input type='datetime' class='form-control' name='birthday'><br />" + "邮箱：<input type='email' class='form-control' name='email'><br />" + "电话：<input type='text' class='form-control' name='telephone'><br />" + "学号：<input type='text' class='form-control' name='studentnumber'><br />" + "学院：<input type='text' class='form-control' name='college'><br />" + "专业：<input class='form-control' type='text' name='major'><br />" + "年级：<input type='text' class='form-control' name='grade'><br />" + "<button type='button' class='btn btn-default' id='btn-userInfoEdit'>确定</button>" + "<button class='btn btn-default' type='button' id='btn-cancel' onclick=''>取消</button>" + "</form>";
            $('.user-info').html(form);
            //取消，返回上一步
            $('#btn-cancel').click(function(){
                //console.log('1');
                url    =   $('.li-user-info a').attr('href');
                location.href = url;
            });
            $('#btn-userInfoEdit').click(function(){
                param = $('.userInfoEditForm').serialize();
                action = '/finder/Home/User/updateUserInfo';
                $.post(action,param,function(data){
                   console.log(data);
                    if(data){
                        location.reload();
                        //location.href = '/finder/Home/User/userManage';
                    }
                });
            });
        });


});
